
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Shape.h>
#include <Rectangle.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Rectangle)
{
	TEST(should be able to calculate the area of Rectangle: 3.351*2.136 = 7.14)
	{
		Rectangle rect(3.351, 2.136); 
		ASSERT_EQ(7.14, rect.getArea());
	}
        TEST(should be able to calculate the perimeter of Rectangle: 2*(3.351+2.136)=10.96)
        {
                Rectangle rect(3.351, 2.136);
                ASSERT_EQ(10.96, rect.getPerimeter());
        }

        TEST(should get 0 if length is invalid when caculate area: length<=0)
        {
                Rectangle rect(0.008, 2);
                ASSERT_EQ(0, rect.getArea());
        }
        TEST(should get 0 if length is invalid when caculate perimeter: length<=0)
        {
                Rectangle rect(0.008, 2);
                ASSERT_EQ(0, rect.getPerimeter());
        }
        TEST(should get 0 if length is invalid when caculate area: length>100)
        {
                Rectangle rect(100.01, 2);
                ASSERT_EQ(0, rect.getArea());
        }
        TEST(should get 0 if length is invalid when caculate perimeter: length>100)
        {
                Rectangle rect(100.01, 2);
                ASSERT_EQ(0, rect.getPerimeter());
        }
        
        TEST(Reset Rectangle with valid rectangle: width = 9.456, length = 16.765)     
       {
                Rectangle rect(0, 0);
                ASSERT_EQ(0, rect.getPerimeter());
                ASSERT_EQ(0, rect.getArea());
                Rectangle rectTemp(9.456, 16.765);
                rect.reset(rectTemp);
                ASSERT_EQ(52.42, rect.getPerimeter());
                ASSERT_EQ(158.38, rect.getArea());
       }
       
       TEST(Reset Rectangle with valid rectangle: width = 0, length = 16.765)
       {
                Rectangle rect(9.456, 16.765);
                ASSERT_EQ(52.42, rect.getPerimeter());
                ASSERT_EQ(158.38, rect.getArea());
                Rectangle rectTemp(0, 16.765);
                rect.reset(rectTemp);
                ASSERT_EQ(52.42, rect.getPerimeter());
                ASSERT_EQ(158.38, rect.getArea());
       }

};

